<section class="content-header">
    <h1>Danh sách đơn hàng</h1>
    <ol class="breadcrumb">
        <li><a href="<?php echo DOMAINAD ?>" ><i class="fa fa-dashboard"></i> Trang chủ</a></li>
        <li class="active">Chi tiết đơn hàng</li>
    </ol>
</section>

<style>
    ul.nav-stacked { margin-top: 20px; border-bottom: 1px solid red; display: block }
    ul.nav-stacked li { border-right: 0px; }
    ul.nav-stacked li a { background-color: #f7f7f7 !important; width: 130px; border-right: 0px; }
    ul.nav-stacked li.active { border-right: 1px solid red; border-right: 0px;}
    ul.nav-stacked li.active  a { background-color: #fff !important; border-right: 0px; }
    ul.nav-stacked.nav-tabs > li > a { border-right: 1px solid #ddd; }
    ul.nav-stacked.nav-tabs > li.active > a { border-right: 1px solid #fff; color: red; font-weight: bold; }
</style>
<!-- Main content -->
<?php echo $this->Form->create(null, array('url' => DOMAINAD . 'order/detail', 'type' => 'post', 'enctype' => 'multipart/form-data', 'name' => 'image')); ?>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <!-- header -->
            <div class="box-header">
                <div class="box-tools">
                    <div class="input-group">
                        <div class="input-group-btn">
                            <a href="javascript:void(0);" onclick="javascript:document.image.submit();" class="btn btn-sm btn-success" ><i class="fa fa-fw fa-plus-circle"></i> Cập nhật đơn hàng </a>
                            <a href="javascript:void(0);" class="btn btn-sm btn-success" onclick="javascript:document.image.reset();">Reset </a>
                            <a href="#messages" rel="modal" class="btn btn-sm btn-warning" > Trợ giúp </a>
                            <a href="<?php echo DOMAINAD; ?>" class="btn btn-sm btn-danger" ><i class="fa fa-fw fa-times-circle"></i> Hủy </a>
                        </div>
                    </div>
                </div>
            </div>
            <!-- /header -->

            <div class="box">
                <div class="box-body table-responsive no-padding">
                    <?php $error = $this->Session->flash(); ?>
                    <?php if (strlen($error) > 45): ?>
                        <div class="alert alert-warning alert-dismissable">
                            <i class="fa fa-warning"></i>
                            <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
                            <?php echo $error; ?>
                        </div>
                    <?php endif; ?>

                    <div class="nav-tabs-custom">
                        <ul class="nav nav-tabs nav-stacked" style="float: left; width: 130px; border-right: 1px solid #ddd; display: block; min-height: 300px; padding-top: 20px">
                            <li class="active" style="border-top: 1px solid #ddd; margin-bottom: 5px; border-bottom: 1px solid #ddd; margin-right: 0px"><a data-toggle="tab" href="general.html#tab_1">Đơn hàng</a></li>
                            <li class="" style="border-top: 1px solid #ddd; border-bottom: 1px solid #ddd; margin-right: 0px"><a data-toggle="tab" href="general.html#tab_2">Sản phẩm</a></li>
                        </ul>
                        <div class="tab-content" style="margin-left: 130px;">
                            <div id="tab_1" class="tab-pane active">
                                <table class="table table-hover table-bordered">
                                    <tr>
                                        <td width="120">Mã đơn hàng: </td>
                                        <td><?php echo $this->data['Order']['id']; ?></td>
                                    </tr>
                                    <tr>
                                        <td width="120">Tên khách hàng: </td>
                                        <td><?php echo $this->data['Order']['username']; ?></td>
                                    </tr>
                                    <tr>
                                        <td width="120">Địa chỉ: </td>
                                        <td><?php echo $this->data['Order']['address']; ?></td>
                                    </tr>
                                    <tr>
                                        <td width="120">Địa chỉ email: </td>
                                        <td><?php echo $this->data['Order']['email']; ?></td>
                                    </tr>
                                    <tr>
                                        <td width="120">Số ĐT</td>
                                        <td><?php echo $this->data['Order']['phone']; ?></td>
                                    </tr>
                                    <tr>
                                        <td width="120">Ngày tạo:</td>
                                        <td><?php echo $this->data['Order']['created']; ?></td>
                                    </tr>
                                    <tr>
                                        <td width="120">Giá trị đơn hàng:</td>
                                        <td><?php echo number_format($this->data['Order']['total_amount']); ?></td>
                                    </tr>
                                    <tr>
                                        <td width="120">Yêu cầu: </td>
                                        <td> </td>
                                    </tr>

                                    <tr>
                                        <td>Trạng thái:</td>
                                        <td>
                                            <?php
                                            echo $this->Form->radio(
                                                'Order.status',
                                                array(0=>'&nbsp;Chưa active&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', 1=>'&nbsp;Active'),
                                                array('legend'=>false, 'style'=>'float: left; cursor: pointer; margin-left: 20px;')
                                            );
                                            ?>
                                        </td>
                                    </tr>
                                </table>
                            </div><!-- /.tab-pane -->
                            <div id="tab_2" class="tab-pane">
                                <table class="table table-hover table-bordered">
                                    <thead>
                                        <tr>
                                            <th style="text-align:left;">STT</th>
                                            <th style="text-align:left; padding-left: 60px;">Tên sản phẩm</th>
                                            <th>Giá sản phẩm</th>
                                            <th style="text-align:center;">Số lượng</th>
                                            <th>Thành tiền</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php
                                        $total_amount = 0;
                                        foreach($this->data['Detail'] as $key => $value){
                                            $amount = $value['OrderDetail']['number_product'] * $value['Product']['price'];
                                            $total_amount += $amount;
                                            $class = $key % 2 == 0 ? 'td_1' : 'td_2';
                                            ?>
                                            <tr class="<?php echo $class; ?>">
                                                <td><?php echo $key+1; ?></td>
                                                <td><?php echo $value['Product']['name']; ?></td>
                                                <td style="text-align:center;"><?php echo number_format($value['Product']['price']); ?></td>
                                                <td style="text-align:center;"><?php echo $value['OrderDetail']['number_product']; ?></td>
                                                <td style="text-align:right;"><?php echo number_format($amount); ?> VND</td>
                                            </tr>
                                        <?php } ?>
                                        <tr>
                                            <th colspan="3" style="text-align:right; padding-right: 10px;">Tổng tiền: </th>
                                            <th colspan="2" style="text-align:right; color: red;"><?php echo number_format($total_amount); ?> VND</th>
                                        </tr>
                                    </tbody>
                                </table>
                            </div><!-- /.tab-pane -->
                        </div><!-- /.tab-content -->
                        <div class="clearfix"></div>
                    </div>
            </div>
        </div>
    </div>
</section>
<?php echo $this->Form->end(); ?>